<html>
<head>
  <title>设备管理系统 - GDMS</title>
  <meta http-equiv="content-type" content="text/html" charset="UTF-8">
  <script type="text/javascript" src="src/js/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="src/js/layui/layui.js"></script>
  <script type="text/javascript" src="src/js/common.js"></script>
  <script type="text/javascript" src="src/js/custom.js"></script>
  <script>
    //如果没有session强制跳转到登录页面
    if(!sessionStorage.access_token){location.href = 'account';}
  </script>
  <link rel="stylesheet" type="text/css" href="src/js/layui/css/layui.css">
  <link rel="stylesheet" type="text/css" href="src/css/bingAdmin.css">
  <link rel="stylesheet" type="text/css" href="src/css/index.css">
</head>
<body>
  <!--顶部导航条-->
  <div class="top-wrap">
    <ul class="layui-nav" lay-filter="">
      <li class="layui-nav-item bing-title">
        <span class="layui-icon layui-icon-component" style="display:none;"></span>
        <span class="title-text" lang="设备管理系统"></span>
      </li>
      <li class="layui-nav-item" style="margin-left:15px;"><i class="layui-icon layui-icon-shrink-right bing-shrink"></i></li>
      <li class="layui-nav-item"><i class="layui-icon layui-icon-refresh-3"></i></li>
      <li class="layui-nav-item">
        <input placeholder="Search..." autocomplete="off" class="layui-input layui-input-search" type="text">
      </li>
      
      <li class="layui-nav-item bing-right"><i class="layui-icon layui-icon-more-vertical"></i></li>
      <li class="layui-nav-item bing-right">
        <a href="javascript:;">
          <span class="bing-username"></span>
          <i class="layui-icon layui-icon-triangle-d"></i> 
        </a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
          <dd style="text-align: center"><a>基本资料</a></dd>
          <dd style="text-align: center"><a>修改密码</a></dd>
          <hr>
          <dd style="text-align: center"><a class="bing-logout">退出</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item bing-right"><i class="layui-icon layui-icon-screen-full bing-screen"></i></li>
      <li class="layui-nav-item bing-right"><i class="layui-icon layui-icon-note"></i></li>
      <li class="layui-nav-item bing-right">
        <a href="javascript:;">Language
          <i class="layui-icon layui-icon-triangle-d"></i> 
        </a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
          <dd style="text-align: center" class="langBtn" lang="CN"><a>中文</a></dd>
          <dd style="text-align: center" class="langBtn" lang="EN"><a>English</a></dd>
        </dl>
      </li>
    </ul>
  </div>
  <!--左侧导航条-->
  <div class="left-wrap">
    <ul class="layui-nav layui-nav-tree" lay-filter="">
      <!--默认展开(layui-nav-itemed)-->
      <li class="layui-nav-item">
        <a href="javascript:;">
          <span class="bing-shrink-show layui-icon layui-icon-home"></span>
          <span lang="主页"></span>
        </a>
        <dl class="layui-nav-child">
          <dd class="viewBtn" view="dashboard"><a><span lang="控制台"></span></a></dd>
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <span class="bing-shrink-show layui-icon layui-icon-app"></span>
          <span lang="设备管理"></span>
        </a>
        <dl class="layui-nav-child">
          <dd class="viewBtn" view="deviceList"><a>设备管理</a></dd>
          <dd class="viewBtn" view="stnList"><a>位置管理</a></dd>
          <dd class="viewBtn" view="styleList"><a>式样管理</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <span class="bing-shrink-show layui-icon layui-icon-template-1"></span>
          <span lang="基础管理"></span>
        </a>
        <dl class="layui-nav-child">
          <dd class="viewBtn" view="siteList"><a>地点管理</a></dd>
          <dd class="viewBtn" view="typeList"><a>类型管理</a></dd>
          <dd class="viewBtn" view="projectList"><a>项目管理</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <span class="bing-shrink-show layui-icon layui-icon-chart"></span>
          <span lang="设备图表"></span>
        </a>
        <dl class="layui-nav-child">
          <dd class="viewBtn" view="chartOld"><a>设备老旧统计</a></dd>
          <dd class="viewBtn" view="chartBackup"><a>设备状态统计</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <span class="bing-shrink-show layui-icon layui-icon-console"></span>
          <span lang="设备监控"></span>
        </a>
        <dl class="layui-nav-child">
          <dd><a>设备监控</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item">
        <a href="javascript:;">
          <span class="bing-shrink-show layui-icon layui-icon-layouts"></span>
          <span lang="系统管理"></span>
        </a>
        <dl class="layui-nav-child">
          <dd class="viewBtn" view="langManage"><a>语言管理</a></dd>
          <dd class="viewBtn" view="systemManage"><a>系统管理</a></dd>
          <dd class="viewBtn" view="userManage"><a>用户管理</a></dd>
        </dl>
      </li>
    </ul>
  </div>
  
  <!--右侧内容容器-->
  <div class="layui-body">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space10" id="view">
        <!-- 视图内容 -->
      </div>
    </div>
  </div>
  
</body>
</html>
<script type="text/javascript">
//顶部导航刷新按钮点击事件
$('.layui-icon-refresh-3').click(function(){
  var view = sessionStorage.viewNow;
  $('#view').load('src/view/'+view+'.html');
});

//初始化页面记录
if(!sessionStorage.viewNow){
  sessionStorage.viewNow = 'dashboard';
  $('dd[view="dashboard"]').addClass('layui-this').parents('.layui-nav-item').addClass('layui-nav-itemed');
}else{
  $('dd[view="'+sessionStorage.viewNow+'"]').addClass('layui-this').parents('.layui-nav-item').addClass('layui-nav-itemed');
}
$('#view').load('src/view/'+sessionStorage.viewNow+'.html');


//导航依赖 element 模块，否则无法进行功能性操作
layui.use(['element','layer'], function(){
  var element = layui.element;
  
  //默认语言变色
  $('dd[lang="'+localStorage.lang+'"]').addClass('layui-this');
  $('.langBtn').click(function(){
    var langNow = $(this).attr('lang');
    localStorage.lang = langNow;
    initLang('index',langNow);
  });
  
  //初始化语言函数
  function initLang(pageName,lang){
    var access_token = sessionStorage.access_token;
    $.ajax({
      url:"api/Lang",
      type: 'post',
      headers:{"Authorization":"Basic "+access_token},
      async:true,
      data: {"pageName":pageName,"lang":lang},
      success:function(res){
        for(var i in res.data){
          $('span[lang="'+i+'"]').html(res.data[i]);
        }
        $('.layui-input-search').attr('placeholder',res.data['搜索']);
      },
      error:function (e) {
        if(e.status == '401'){
          Logout();   //退出登录
        }else{
          var errMsg = 'Error';
          if(e.status){errMsg = errMsg +'(' + e.status + ')';}
          layer.msg(errMsg, {
            icon: 3,
            time: 1500 //1.5秒关闭
          }, function(){
          });
        }
      }
    });
  }
  var langNow = localStorage.lang;
  initLang('index',langNow);
  
});

//左侧导航 - 按钮分类点击事件
$('.left-wrap').find('.layui-nav-item').click(function(){
  if($('.bing-shrink').hasClass('layui-icon-spread-left')){
    $('.bing-shrink').click();
  }
  $(this).siblings().removeClass('layui-nav-itemed');
});

//顶部导航 - 收缩按钮事件
$('.bing-shrink').click(function(){
  if($(this).hasClass('layui-icon-shrink-right')){
    $('.bing-title').find('.title-text').hide().end().find('.layui-icon').show().end().animate({width:"55px"},200);
    $('.layui-nav-tree').animate({width:"55px"},200);
    $('.layui-body').animate({left:"55px"},200);
    $('.left-wrap').find('.layui-nav-item').find('span').hide()
    $('.left-wrap').find('.layui-nav-item').find('.bing-shrink-show').show();
    $('.left-wrap').find('.layui-nav-itemed').removeClass('layui-nav-itemed').css('background-color','rgba(0,0,0,.3)').find('a').css('color','#fff');
    $(this).addClass('layui-icon-spread-left').removeClass('layui-icon-shrink-right');
  }else{
    $('.bing-title').animate({width:"190px"},200,function() {
      $(this).find('.layui-icon').hide().end().find('.title-text').show();
    });
    $('.left-wrap').find('.layui-nav-item').css('background-color','').find('a').css('color','');
    $('.layui-nav-tree').animate({width:"190px"},200,function() {
      $('.left-wrap').find('.layui-nav-item').find('span').show()
    });
    $('.layui-body').animate({left:"190px"},200);
    $('.left-wrap').find('.layui-this').parents('.layui-nav-item').addClass('layui-nav-itemed');
    $(this).addClass('layui-icon-shrink-right').removeClass('layui-icon-spread-left');
  }
});

//顶部导航 - 全屏按钮事件
$('.bing-screen').click(function(){
  if($(this).hasClass('layui-icon-screen-full')){
    requestFullScreen();
    $(this).addClass('layui-icon-screen-restore').removeClass('layui-icon-screen-full');
  }else{
    exitFullscreen();
    $(this).addClass('layui-icon-screen-full').removeClass('layui-icon-screen-restore');
  }
});

//顶部导航 - 便签功能
$('.layui-icon-note').click(function(){
  if($('.note-input').length == 0){
    var width = $(window).width();
    if(localStorage.note==undefined){
      localStorage.note = '';
    }
    layer.open({
      type: 1,
      skin: 'layer-note', //加上边框
      offset:['50px',(width-495)],
      title:'便签',
      shade:0,
      resize:false,
      anim:1,
      content: '<textarea class="note-input">'+localStorage.note+'</textarea> '
    });
    $('.note-input').bind('input',function(){
      localStorage.note = $(this).val();
    });
  }
});

//引用退出控制器
loadJS('src/controllers/Logout.js',function(){
  //用户退出登录按钮点击事件
  $('.bing-logout').click(function(){
    Logout();
  });

});

//用户名初始化
$('.bing-username').text(sessionStorage.username);

//左侧导航 - 按钮点击事件
$('.viewBtn').click(function(){
  var view = $(this).attr('view');
  sessionStorage.viewNow = view;
  $('#view').load('src/view/'+view+'.html');
});



</script>


